package com.s64.mq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 订单消息的生产者，生成一个订单消息，并放入指定的exchange
 */
@Component
public class OrderProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

   /* public void createOrder(Order order) {
        rabbitTemplate.convertAndSend("s64.exchange1", "new", order);
        System.out.println("发送订单创建消息成功:" + order.getOrderNo());
    }

    public void delOrder(Order order) {
        rabbitTemplate.convertAndSend("s64.exchange1", "delete", order);
        System.out.println("发送订单删除消息成功:" + order.getOrderNo());
    }*/
  /* public void createOrder(Order order) {
       rabbitTemplate.convertAndSend("s64.exchange2", "order.new", order);
       System.out.println("发送订单创建消息成功:" + order.getOrderNo());
   }

    public void delOrder(Order order) {
        rabbitTemplate.convertAndSend("s64.exchange2", "order.delete", order);
        System.out.println("发送订单删除消息成功:" + order.getOrderNo());
    }*/
   public void createOrder(Order order) {
       rabbitTemplate.convertAndSend("s64.exchange3", "", order);
       System.out.println("发送订单创建消息成功:" + order.getOrderNo());
   }

    public void delOrder(Order order) {
        rabbitTemplate.convertAndSend("s64.exchange3", "", order);
        System.out.println("发送订单删除消息成功:" + order.getOrderNo());
    }
}
